const mysql = require('mysql');

const db = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'alipay-demo'
})

// 测试mysql模块能否正常工作
db.query('SELECT 1', (error, results) => {
    if (error) return console.log(error.message);
    // 成功的话 打印出 [ RowDataPacket { '1': 1 } ]
    console.log(results);
})

const select = 'select * from goods'

db.query(select, (error, results) => {
    if (error) {
        return console.log(error.message);
    }
    console.log(results);
})